import React from 'react';
import { Routes, Route, Navigate } from 'react-router-dom';
import AppLayout from './components/Layout/Layout';
import AuthGuard from './components/AuthGuard/AuthGuard';
import Home from './pages/Home/Home';
import Discussion from './pages/Posts/Discussion';
import PostDetail from './pages/Posts/PostDetail';
import Share from './pages/Posts/Share';
import Trade from './pages/Posts/Trade';
import Help from './pages/Posts/Help';
import Activities from './pages/Activities/Activities';
import Knowledge from './pages/Knowledge/Knowledge';
import Products from './pages/Products/Products';
import ChatRoom from './pages/Chat/ChatRoom';
import Login from './pages/Auth/Login';
import Register from './pages/Auth/Register';
import ForgotPassword from './pages/Auth/ForgotPassword';
import VerifyDemo from './pages/VerifyDemo/VerifyDemo';

const App: React.FC = () => {
  return (
    <Routes>
      {/* 公开路由 - 无需登录 */}
      <Route path="/login" element={<Login />} />
      <Route path="/register" element={<Register />} />
      <Route path="/forgot-password" element={<ForgotPassword />} />

      {/* 受保护路由 - 需要登录 */}
      <Route
        path="/"
        element={
          <AuthGuard>
            <AppLayout />
          </AuthGuard>
        }
      >
        <Route index element={<Home />} />
        <Route path="posts/discussion" element={<Discussion />} />
        <Route path="posts/discussion/:id" element={<PostDetail />} />
        <Route path="posts/share" element={<Share />} />
        <Route path="posts/share/:id" element={<PostDetail />} />
        <Route path="posts/trade" element={<Trade />} />
        <Route path="posts/trade/:id" element={<PostDetail />} />
        <Route path="posts/help" element={<Help />} />
        <Route path="activities" element={<Activities />} />
        <Route path="knowledge" element={<Knowledge />} />
        <Route path="products" element={<Products />} />
        <Route path="chat" element={<ChatRoom />} />
        <Route path="verify-demo" element={<VerifyDemo />} />
        <Route path="*" element={<Navigate to="/" replace />} />
      </Route>
    </Routes>
  );
};

export default App;